/**
 * MediaFrame is an Open Source streaming media platform in Java 
 * which provides a fast, easy to implement and extremely small applet 
 * that enables to view your audio/video content without having 
 * to rely on external player applications or bulky plug-ins.
 * 
 * Copyright (C) 2004/5 MediaFrame (http://www.mediaframe.org).
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 */
/************************** MPEG-2 NBC Audio Decoder **************************
 *                                                                           
 * "This software module was originally developed by 
 * AT&T, Dolby Laboratories, Fraunhofer Gesellschaft IIS in the course of 
 * development of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 
 * 14496-1,2 and 3. This software module is an implementation of a part of one or more 
 * MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 
 * Audio standard. ISO/IEC  gives users of the MPEG-2 NBC/MPEG-4 Audio 
 * standards free license to this software module or modifications thereof for use in 
 * hardware or software products claiming conformance to the MPEG-2 NBC/MPEG-4
 * Audio  standards. Those intending to use this software module in hardware or 
 * software products are advised that this use may infringe existing patents. 
 * The original developer of this software module and his/her company, the subsequent 
 * editors and their companies, and ISO/IEC have no liability for use of this software 
 * module or modifications thereof in an implementation. Copyright is not released for 
 * non MPEG-2 NBC/MPEG-4 Audio conforming products.The original developer
 * retains full right to use the code for his/her  own purpose, assign or donate the 
 * code to a third party and to inhibit third party from using the code for non 
 * MPEG-2 NBC/MPEG-4 Audio conforming products. This copyright notice must
 * be included in all copies or derivative works." 
 * Copyright(c)1996.
 * 
 ******************************************************************************/                                                                          
package mediaframe.mpeg4.audio.AAC;

import java.io.IOException;

public class Huffman {

	public final int[][] book1 = {
		/*index  length  codeword */
		{     0,     11,     2040},
		{     1,      9,      497},
		{     2,     11,     2045},
		{     3,     10,     1013},
		{     4,      7,      104},
		{     5,     10,     1008},
		{     6,     11,     2039},
		{     7,      9,      492},
		{     8,     11,     2037},
		{     9,     10,     1009},
		{    10,      7,      114},
		{    11,     10,     1012},
		{    12,      7,      116},
		{    13,      5,       17},
		{    14,      7,      118},
		{    15,      9,      491},
		{    16,      7,      108},
		{    17,     10,     1014},
		{    18,     11,     2044},
		{    19,      9,      481},
		{    20,     11,     2033},
		{    21,      9,      496},
		{    22,      7,       97},
		{    23,      9,      502},
		{    24,     11,     2034},
		{    25,      9,      490},
		{    26,     11,     2043},
		{    27,      9,      498},
		{    28,      7,      105},
		{    29,      9,      493},
		{    30,      7,      119},
		{    31,      5,       23},
		{    32,      7,      111},
		{    33,      9,      486},
		{    34,      7,      100},
		{    35,      9,      485},
		{    36,      7,      103},
		{    37,      5,       21},
		{    38,      7,       98},
		{    39,      5,       18},
		{    40,      1,        0},
		{    41,      5,       20},
		{    42,      7,      101},
		{    43,      5,       22},
		{    44,      7,      109},
		{    45,      9,      489},
		{    46,      7,       99},
		{    47,      9,      484},
		{    48,      7,      107},
		{    49,      5,       19},
		{    50,      7,      113},
		{    51,      9,      483},
		{    52,      7,      112},
		{    53,      9,      499},
		{    54,     11,     2046},
		{    55,      9,      487},
		{    56,     11,     2035},
		{    57,      9,      495},
		{    58,      7,       96},
		{    59,      9,      494},
		{    60,     11,     2032},
		{    61,      9,      482},
		{    62,     11,     2042},
		{    63,     10,     1011},
		{    64,      7,      106},
		{    65,      9,      488},
		{    66,      7,      117},
		{    67,      5,       16},
		{    68,      7,      115},
		{    69,      9,      500},
		{    70,      7,      110},
		{    71,     10,     1015},
		{    72,     11,     2038},
		{    73,      9,      480},
		{    74,     11,     2041},
		{    75,     10,     1010},
		{    76,      7,      102},
		{    77,      9,      501},
		{    78,     11,     2047},
		{    79,      9,      503},
		{    80,     11,     2036}
	};

	public final int[][] book2 = {
		/*index  length  codeword */
		{     0,      9,      499},
		{     1,      7,      111},
		{     2,      9,      509},
		{     3,      8,      235},
		{     4,      6,       35},
		{     5,      8,      234},
		{     6,      9,      503},
		{     7,      8,      232},
		{     8,      9,      506},
		{     9,      8,      242},
		{    10,      6,       45},
		{    11,      7,      112},
		{    12,      6,       32},
		{    13,      5,        6},
		{    14,      6,       43},
		{    15,      7,      110},
		{    16,      6,       40},
		{    17,      8,      233},
		{    18,      9,      505},
		{    19,      7,      102},
		{    20,      8,      248},
		{    21,      8,      231},
		{    22,      6,       27},
		{    23,      8,      241},
		{    24,      9,      500},
		{    25,      7,      107},
		{    26,      9,      501},
		{    27,      8,      236},
		{    28,      6,       42},
		{    29,      7,      108},
		{    30,      6,       44},
		{    31,      5,       10},
		{    32,      6,       39},
		{    33,      7,      103},
		{    34,      6,       26},
		{    35,      8,      245},
		{    36,      6,       36},
		{    37,      5,        8},
		{    38,      6,       31},
		{    39,      5,        9},
		{    40,      3,        0},
		{    41,      5,        7},
		{    42,      6,       29},
		{    43,      5,       11},
		{    44,      6,       48},
		{    45,      8,      239},
		{    46,      6,       28},
		{    47,      7,      100},
		{    48,      6,       30},
		{    49,      5,       12},
		{    50,      6,       41},
		{    51,      8,      243},
		{    52,      6,       47},
		{    53,      8,      240},
		{    54,      9,      508},
		{    55,      7,      113},
		{    56,      9,      498},
		{    57,      8,      244},
		{    58,      6,       33},
		{    59,      8,      230},
		{    60,      8,      247},
		{    61,      7,      104},
		{    62,      9,      504},
		{    63,      8,      238},
		{    64,      6,       34},
		{    65,      7,      101},
		{    66,      6,       49},
		{    67,      4,        2},
		{    68,      6,       38},
		{    69,      8,      237},
		{    70,      6,       37},
		{    71,      7,      106},
		{    72,      9,      507},
		{    73,      7,      114},
		{    74,      9,      510},
		{    75,      7,      105},
		{    76,      6,       46},
		{    77,      8,      246},
		{    78,      9,      511},
		{    79,      7,      109},
		{    80,      9,      502}
	};

	public final int[][] book3 = {
		/*index  length  codeword */
		{     0,      1,        0},
		{     1,      4,        9},
		{     2,      8,      239},
		{     3,      4,       11},
		{     4,      5,       25},
		{     5,      8,      240},
		{     6,      9,      491},
		{     7,      9,      486},
		{     8,     10,     1010},
		{     9,      4,       10},
		{    10,      6,       53},
		{    11,      9,      495},
		{    12,      6,       52},
		{    13,      6,       55},
		{    14,      9,      489},
		{    15,      9,      493},
		{    16,      9,      487},
		{    17,     10,     1011},
		{    18,      9,      494},
		{    19,     10,     1005},
		{    20,     13,     8186},
		{    21,      9,      492},
		{    22,      9,      498},
		{    23,     11,     2041},
		{    24,     11,     2040},
		{    25,     10,     1016},
		{    26,     12,     4088},
		{    27,      4,        8},
		{    28,      6,       56},
		{    29,     10,     1014},
		{    30,      6,       54},
		{    31,      7,      117},
		{    32,     10,     1009},
		{    33,     10,     1003},
		{    34,     10,     1004},
		{    35,     12,     4084},
		{    36,      5,       24},
		{    37,      7,      118},
		{    38,     11,     2036},
		{    39,      6,       57},
		{    40,      7,      116},
		{    41,     10,     1007},
		{    42,      9,      499},
		{    43,      9,      500},
		{    44,     11,     2038},
		{    45,      9,      488},
		{    46,     10,     1002},
		{    47,     13,     8188},
		{    48,      8,      242},
		{    49,      9,      497},
		{    50,     12,     4091},
		{    51,     10,     1013},
		{    52,     11,     2035},
		{    53,     12,     4092},
		{    54,      8,      238},
		{    55,     10,     1015},
		{    56,     15,    32766},
		{    57,      9,      496},
		{    58,     11,     2037},
		{    59,     15,    32765},
		{    60,     13,     8187},
		{    61,     14,    16378},
		{    62,     16,    65535},
		{    63,      8,      241},
		{    64,     10,     1008},
		{    65,     14,    16380},
		{    66,      9,      490},
		{    67,     10,     1006},
		{    68,     14,    16379},
		{    69,     12,     4086},
		{    70,     12,     4090},
		{    71,     15,    32764},
		{    72,     11,     2034},
		{    73,     12,     4085},
		{    74,     16,    65534},
		{    75,     10,     1012},
		{    76,     11,     2039},
		{    77,     15,    32763},
		{    78,     12,     4087},
		{    79,     12,     4089},
		{    80,     15,    32762}
	};

	public final int[][] book4 = {
		/*index  length  codeword */
		{     0,      4,        7},
		{     1,      5,       22},
		{     2,      8,      246},
		{     3,      5,       24},
		{     4,      4,        8},
		{     5,      8,      239},
		{     6,      9,      495},
		{     7,      8,      243},
		{     8,     11,     2040},
		{     9,      5,       25},
		{    10,      5,       23},
		{    11,      8,      237},
		{    12,      5,       21},
		{    13,      4,        1},
		{    14,      8,      226},
		{    15,      8,      240},
		{    16,      7,      112},
		{    17,     10,     1008},
		{    18,      9,      494},
		{    19,      8,      241},
		{    20,     11,     2042},
		{    21,      8,      238},
		{    22,      8,      228},
		{    23,     10,     1010},
		{    24,     11,     2038},
		{    25,     10,     1007},
		{    26,     11,     2045},
		{    27,      4,        5},
		{    28,      5,       20},
		{    29,      8,      242},
		{    30,      4,        9},
		{    31,      4,        4},
		{    32,      8,      229},
		{    33,      8,      244},
		{    34,      8,      232},
		{    35,     10,     1012},
		{    36,      4,        6},
		{    37,      4,        2},
		{    38,      8,      231},
		{    39,      4,        3},
		{    40,      4,        0},
		{    41,      7,      107},
		{    42,      8,      227},
		{    43,      7,      105},
		{    44,      9,      499},
		{    45,      8,      235},
		{    46,      8,      230},
		{    47,     10,     1014},
		{    48,      7,      110},
		{    49,      7,      106},
		{    50,      9,      500},
		{    51,     10,     1004},
		{    52,      9,      496},
		{    53,     10,     1017},
		{    54,      8,      245},
		{    55,      8,      236},
		{    56,     11,     2043},
		{    57,      8,      234},
		{    58,      7,      111},
		{    59,     10,     1015},
		{    60,     11,     2041},
		{    61,     10,     1011},
		{    62,     12,     4095},
		{    63,      8,      233},
		{    64,      7,      109},
		{    65,     10,     1016},
		{    66,      7,      108},
		{    67,      7,      104},
		{    68,      9,      501},
		{    69,     10,     1006},
		{    70,      9,      498},
		{    71,     11,     2036},
		{    72,     11,     2039},
		{    73,     10,     1009},
		{    74,     12,     4094},
		{    75,     10,     1005},
		{    76,      9,      497},
		{    77,     11,     2037},
		{    78,     11,     2046},
		{    79,     10,     1013},
		{    80,     11,     2044}
	};

	public final int[][] book5 = {
		/*index  length  codeword */
		{     0,     13,     8191},
		{     1,     12,     4087},
		{     2,     11,     2036},
		{     3,     11,     2024},
		{     4,     10,     1009},
		{     5,     11,     2030},
		{     6,     11,     2041},
		{     7,     12,     4088},
		{     8,     13,     8189},
		{     9,     12,     4093},
		{    10,     11,     2033},
		{    11,     10,     1000},
		{    12,      9,      488},
		{    13,      8,      240},
		{    14,      9,      492},
		{    15,     10,     1006},
		{    16,     11,     2034},
		{    17,     12,     4090},
		{    18,     12,     4084},
		{    19,     10,     1007},
		{    20,      9,      498},
		{    21,      8,      232},
		{    22,      7,      112},
		{    23,      8,      236},
		{    24,      9,      496},
		{    25,     10,     1002},
		{    26,     11,     2035},
		{    27,     11,     2027},
		{    28,      9,      491},
		{    29,      8,      234},
		{    30,      5,       26},
		{    31,      4,        8},
		{    32,      5,       25},
		{    33,      8,      238},
		{    34,      9,      495},
		{    35,     11,     2029},
		{    36,     10,     1008},
		{    37,      8,      242},
		{    38,      7,      115},
		{    39,      4,       11},
		{    40,      1,        0},
		{    41,      4,       10},
		{    42,      7,      113},
		{    43,      8,      243},
		{    44,     11,     2025},
		{    45,     11,     2031},
		{    46,      9,      494},
		{    47,      8,      239},
		{    48,      5,       24},
		{    49,      4,        9},
		{    50,      5,       27},
		{    51,      8,      235},
		{    52,      9,      489},
		{    53,     11,     2028},
		{    54,     11,     2038},
		{    55,     10,     1003},
		{    56,      9,      499},
		{    57,      8,      237},
		{    58,      7,      114},
		{    59,      8,      233},
		{    60,      9,      497},
		{    61,     10,     1005},
		{    62,     11,     2039},
		{    63,     12,     4086},
		{    64,     11,     2032},
		{    65,     10,     1001},
		{    66,      9,      493},
		{    67,      8,      241},
		{    68,      9,      490},
		{    69,     10,     1004},
		{    70,     11,     2040},
		{    71,     12,     4089},
		{    72,     13,     8188},
		{    73,     12,     4092},
		{    74,     12,     4085},
		{    75,     11,     2026},
		{    76,     10,     1011},
		{    77,     10,     1010},
		{    78,     11,     2037},
		{    79,     12,     4091},
		{    80,     13,     8190}
	};

	public final int[][] book6 = {
		/*index  length  codeword */
		{     0,     11,     2046},
		{     1,     10,     1021},
		{     2,      9,      497},
		{     3,      9,      491},
		{     4,      9,      500},
		{     5,      9,      490},
		{     6,      9,      496},
		{     7,     10,     1020},
		{     8,     11,     2045},
		{     9,     10,     1014},
		{    10,      9,      485},
		{    11,      8,      234},
		{    12,      7,      108},
		{    13,      7,      113},
		{    14,      7,      104},
		{    15,      8,      240},
		{    16,      9,      486},
		{    17,     10,     1015},
		{    18,      9,      499},
		{    19,      8,      239},
		{    20,      6,       50},
		{    21,      6,       39},
		{    22,      6,       40},
		{    23,      6,       38},
		{    24,      6,       49},
		{    25,      8,      235},
		{    26,      9,      503},
		{    27,      9,      488},
		{    28,      7,      111},
		{    29,      6,       46},
		{    30,      4,        8},
		{    31,      4,        4},
		{    32,      4,        6},
		{    33,      6,       41},
		{    34,      7,      107},
		{    35,      9,      494},
		{    36,      9,      495},
		{    37,      7,      114},
		{    38,      6,       45},
		{    39,      4,        2},
		{    40,      4,        0},
		{    41,      4,        3},
		{    42,      6,       47},
		{    43,      7,      115},
		{    44,      9,      506},
		{    45,      9,      487},
		{    46,      7,      110},
		{    47,      6,       43},
		{    48,      4,        7},
		{    49,      4,        1},
		{    50,      4,        5},
		{    51,      6,       44},
		{    52,      7,      109},
		{    53,      9,      492},
		{    54,      9,      505},
		{    55,      8,      238},
		{    56,      6,       48},
		{    57,      6,       36},
		{    58,      6,       42},
		{    59,      6,       37},
		{    60,      6,       51},
		{    61,      8,      236},
		{    62,      9,      498},
		{    63,     10,     1016},
		{    64,      9,      484},
		{    65,      8,      237},
		{    66,      7,      106},
		{    67,      7,      112},
		{    68,      7,      105},
		{    69,      7,      116},
		{    70,      8,      241},
		{    71,     10,     1018},
		{    72,     11,     2047},
		{    73,     10,     1017},
		{    74,      9,      502},
		{    75,      9,      493},
		{    76,      9,      504},
		{    77,      9,      489},
		{    78,      9,      501},
		{    79,     10,     1019},
		{    80,     11,     2044}
	};

	public final int[][] book7 = {
		/*index  length  codeword */
		{     0,      1,        0},
		{     1,      3,        5},
		{     2,      6,       55},
		{     3,      7,      116},
		{     4,      8,      242},
		{     5,      9,      491},
		{     6,     10,     1005},
		{     7,     11,     2039},
		{     8,      3,        4},
		{     9,      4,       12},
		{    10,      6,       53},
		{    11,      7,      113},
		{    12,      8,      236},
		{    13,      8,      238},
		{    14,      9,      494},
		{    15,      9,      501},
		{    16,      6,       54},
		{    17,      6,       52},
		{    18,      7,      114},
		{    19,      8,      234},
		{    20,      8,      241},
		{    21,      9,      489},
		{    22,      9,      499},
		{    23,     10,     1013},
		{    24,      7,      115},
		{    25,      7,      112},
		{    26,      8,      235},
		{    27,      8,      240},
		{    28,      9,      497},
		{    29,      9,      496},
		{    30,     10,     1004},
		{    31,     10,     1018},
		{    32,      8,      243},
		{    33,      8,      237},
		{    34,      9,      488},
		{    35,      9,      495},
		{    36,     10,     1007},
		{    37,     10,     1009},
		{    38,     10,     1017},
		{    39,     11,     2043},
		{    40,      9,      493},
		{    41,      8,      239},
		{    42,      9,      490},
		{    43,      9,      498},
		{    44,     10,     1011},
		{    45,     10,     1016},
		{    46,     11,     2041},
		{    47,     11,     2044},
		{    48,     10,     1006},
		{    49,      9,      492},
		{    50,      9,      500},
		{    51,     10,     1012},
		{    52,     10,     1015},
		{    53,     11,     2040},
		{    54,     12,     4093},
		{    55,     12,     4094},
		{    56,     11,     2038},
		{    57,     10,     1008},
		{    58,     10,     1010},
		{    59,     10,     1014},
		{    60,     11,     2042},
		{    61,     11,     2045},
		{    62,     12,     4092},
		{    63,     12,     4095}
	};

	public final int[][] book8 = {
		/*index  length  codeword */
		{     0,      5,       14},
		{     1,      4,        5},
		{     2,      5,       16},
		{     3,      6,       48},
		{     4,      7,      111},
		{     5,      8,      241},
		{     6,      9,      506},
		{     7,     10,     1022},
		{     8,      4,        3},
		{     9,      3,        0},
		{    10,      4,        4},
		{    11,      5,       18},
		{    12,      6,       44},
		{    13,      7,      106},
		{    14,      7,      117},
		{    15,      8,      248},
		{    16,      5,       15},
		{    17,      4,        2},
		{    18,      4,        6},
		{    19,      5,       20},
		{    20,      6,       46},
		{    21,      7,      105},
		{    22,      7,      114},
		{    23,      8,      245},
		{    24,      6,       47},
		{    25,      5,       17},
		{    26,      5,       19},
		{    27,      6,       42},
		{    28,      6,       50},
		{    29,      7,      108},
		{    30,      8,      236},
		{    31,      8,      250},
		{    32,      7,      113},
		{    33,      6,       43},
		{    34,      6,       45},
		{    35,      6,       49},
		{    36,      7,      109},
		{    37,      7,      112},
		{    38,      8,      242},
		{    39,      9,      505},
		{    40,      8,      239},
		{    41,      7,      104},
		{    42,      6,       51},
		{    43,      7,      107},
		{    44,      7,      110},
		{    45,      8,      238},
		{    46,      8,      249},
		{    47,     10,     1020},
		{    48,      9,      504},
		{    49,      7,      116},
		{    50,      7,      115},
		{    51,      8,      237},
		{    52,      8,      240},
		{    53,      8,      246},
		{    54,      9,      502},
		{    55,      9,      509},
		{    56,     10,     1021},
		{    57,      8,      243},
		{    58,      8,      244},
		{    59,      8,      247},
		{    60,      9,      503},
		{    61,      9,      507},
		{    62,      9,      508},
		{    63,     10,     1023}
	};

	public final int[][] book9 = {
		/*index  length  codeword */
		{     0,      1,        0},
		{     1,      3,        5},
		{     2,      6,       55},
		{     3,      8,      231},
		{     4,      9,      478},
		{     5,     10,      974},
		{     6,     10,      985},
		{     7,     11,     1992},
		{     8,     11,     1997},
		{     9,     12,     4040},
		{    10,     12,     4061},
		{    11,     13,     8164},
		{    12,     13,     8172},
		{    13,      3,        4},
		{    14,      4,       12},
		{    15,      6,       53},
		{    16,      7,      114},
		{    17,      8,      234},
		{    18,      8,      237},
		{    19,      9,      482},
		{    20,     10,      977},
		{    21,     10,      979},
		{    22,     10,      992},
		{    23,     11,     2008},
		{    24,     12,     4047},
		{    25,     12,     4053},
		{    26,      6,       54},
		{    27,      6,       52},
		{    28,      7,      113},
		{    29,      8,      232},
		{    30,      8,      236},
		{    31,      9,      481},
		{    32,     10,      975},
		{    33,     10,      989},
		{    34,     10,      987},
		{    35,     11,     2000},
		{    36,     12,     4039},
		{    37,     12,     4052},
		{    38,     12,     4068},
		{    39,      8,      230},
		{    40,      7,      112},
		{    41,      8,      233},
		{    42,      9,      477},
		{    43,      9,      483},
		{    44,     10,      978},
		{    45,     10,      988},
		{    46,     11,     1996},
		{    47,     11,     1994},
		{    48,     11,     2014},
		{    49,     12,     4056},
		{    50,     12,     4074},
		{    51,     13,     8155},
		{    52,      9,      479},
		{    53,      8,      235},
		{    54,      9,      476},
		{    55,      9,      486},
		{    56,     10,      981},
		{    57,     10,      990},
		{    58,     11,     1995},
		{    59,     11,     2013},
		{    60,     11,     2012},
		{    61,     12,     4045},
		{    62,     12,     4066},
		{    63,     12,     4071},
		{    64,     13,     8161},
		{    65,     10,      976},
		{    66,      9,      480},
		{    67,      9,      484},
		{    68,     10,      982},
		{    69,     11,     1989},
		{    70,     11,     2001},
		{    71,     11,     2011},
		{    72,     12,     4050},
		{    73,     11,     2016},
		{    74,     12,     4057},
		{    75,     12,     4075},
		{    76,     13,     8163},
		{    77,     13,     8169},
		{    78,     11,     1988},
		{    79,      9,      485},
		{    80,     10,      983},
		{    81,     11,     1990},
		{    82,     11,     1999},
		{    83,     11,     2010},
		{    84,     12,     4043},
		{    85,     12,     4058},
		{    86,     12,     4067},
		{    87,     12,     4073},
		{    88,     13,     8166},
		{    89,     13,     8179},
		{    90,     13,     8183},
		{    91,     11,     2003},
		{    92,     10,      984},
		{    93,     10,      993},
		{    94,     11,     2004},
		{    95,     11,     2009},
		{    96,     12,     4051},
		{    97,     12,     4062},
		{    98,     13,     8157},
		{    99,     13,     8153},
		{   100,     13,     8162},
		{   101,     13,     8170},
		{   102,     13,     8177},
		{   103,     13,     8182},
		{   104,     11,     2002},
		{   105,     10,      980},
		{   106,     10,      986},
		{   107,     11,     1991},
		{   108,     11,     2007},
		{   109,     11,     2018},
		{   110,     12,     4046},
		{   111,     12,     4059},
		{   112,     13,     8152},
		{   113,     13,     8174},
		{   114,     14,    16368},
		{   115,     13,     8180},
		{   116,     14,    16370},
		{   117,     11,     2017},
		{   118,     10,      991},
		{   119,     11,     1993},
		{   120,     11,     2006},
		{   121,     12,     4042},
		{   122,     12,     4048},
		{   123,     12,     4069},
		{   124,     12,     4070},
		{   125,     13,     8171},
		{   126,     13,     8175},
		{   127,     14,    16371},
		{   128,     14,    16372},
		{   129,     14,    16373},
		{   130,     12,     4064},
		{   131,     11,     1998},
		{   132,     11,     2005},
		{   133,     12,     4038},
		{   134,     12,     4049},
		{   135,     12,     4065},
		{   136,     13,     8160},
		{   137,     13,     8168},
		{   138,     13,     8176},
		{   139,     14,    16369},
		{   140,     14,    16376},
		{   141,     14,    16374},
		{   142,     15,    32764},
		{   143,     12,     4072},
		{   144,     11,     2015},
		{   145,     12,     4041},
		{   146,     12,     4055},
		{   147,     12,     4060},
		{   148,     13,     8156},
		{   149,     13,     8159},
		{   150,     13,     8173},
		{   151,     13,     8181},
		{   152,     14,    16377},
		{   153,     14,    16379},
		{   154,     15,    32765},
		{   155,     15,    32766},
		{   156,     13,     8167},
		{   157,     12,     4044},
		{   158,     12,     4054},
		{   159,     12,     4063},
		{   160,     13,     8158},
		{   161,     13,     8154},
		{   162,     13,     8165},
		{   163,     13,     8178},
		{   164,     14,    16378},
		{   165,     14,    16375},
		{   166,     14,    16380},
		{   167,     14,    16381},
		{   168,     15,    32767}
	};

	public final int[][] book10 = {
		/*index  length  codeword */
		{     0,      6,       34},
		{     1,      5,        8},
		{     2,      6,       29},
		{     3,      6,       38},
		{     4,      7,       95},
		{     5,      8,      211},
		{     6,      9,      463},
		{     7,     10,      976},
		{     8,     10,      983},
		{     9,     10,     1005},
		{    10,     11,     2032},
		{    11,     11,     2038},
		{    12,     12,     4093},
		{    13,      5,        7},
		{    14,      4,        0},
		{    15,      4,        1},
		{    16,      5,        9},
		{    17,      6,       32},
		{    18,      7,       84},
		{    19,      7,       96},
		{    20,      8,      213},
		{    21,      8,      220},
		{    22,      9,      468},
		{    23,     10,      973},
		{    24,     10,      990},
		{    25,     11,     2023},
		{    26,      6,       28},
		{    27,      4,        2},
		{    28,      5,        6},
		{    29,      5,       12},
		{    30,      6,       30},
		{    31,      6,       40},
		{    32,      7,       91},
		{    33,      8,      205},
		{    34,      8,      217},
		{    35,      9,      462},
		{    36,      9,      476},
		{    37,     10,      985},
		{    38,     10,     1009},
		{    39,      6,       37},
		{    40,      5,       11},
		{    41,      5,       10},
		{    42,      5,       13},
		{    43,      6,       36},
		{    44,      7,       87},
		{    45,      7,       97},
		{    46,      8,      204},
		{    47,      8,      221},
		{    48,      9,      460},
		{    49,      9,      478},
		{    50,     10,      979},
		{    51,     10,      999},
		{    52,      7,       93},
		{    53,      6,       33},
		{    54,      6,       31},
		{    55,      6,       35},
		{    56,      6,       39},
		{    57,      7,       89},
		{    58,      7,      100},
		{    59,      8,      216},
		{    60,      8,      223},
		{    61,      9,      466},
		{    62,      9,      482},
		{    63,     10,      989},
		{    64,     10,     1006},
		{    65,      8,      209},
		{    66,      7,       85},
		{    67,      6,       41},
		{    68,      7,       86},
		{    69,      7,       88},
		{    70,      7,       98},
		{    71,      8,      206},
		{    72,      8,      224},
		{    73,      8,      226},
		{    74,      9,      474},
		{    75,     10,      980},
		{    76,     10,      995},
		{    77,     11,     2027},
		{    78,      9,      457},
		{    79,      7,       94},
		{    80,      7,       90},
		{    81,      7,       92},
		{    82,      7,       99},
		{    83,      8,      202},
		{    84,      8,      218},
		{    85,      9,      455},
		{    86,      9,      458},
		{    87,      9,      480},
		{    88,     10,      987},
		{    89,     10,     1000},
		{    90,     11,     2028},
		{    91,      9,      483},
		{    92,      8,      210},
		{    93,      8,      203},
		{    94,      8,      208},
		{    95,      8,      215},
		{    96,      8,      219},
		{    97,      9,      454},
		{    98,      9,      469},
		{    99,      9,      472},
		{   100,     10,      970},
		{   101,     10,      986},
		{   102,     11,     2026},
		{   103,     11,     2033},
		{   104,      9,      481},
		{   105,      8,      212},
		{   106,      8,      207},
		{   107,      8,      214},
		{   108,      8,      222},
		{   109,      8,      225},
		{   110,      9,      464},
		{   111,      9,      470},
		{   112,     10,      977},
		{   113,     10,      981},
		{   114,     10,     1010},
		{   115,     11,     2030},
		{   116,     11,     2043},
		{   117,     10,     1001},
		{   118,      9,      461},
		{   119,      9,      456},
		{   120,      9,      459},
		{   121,      9,      465},
		{   122,      9,      471},
		{   123,      9,      479},
		{   124,     10,      975},
		{   125,     10,      992},
		{   126,     10,     1007},
		{   127,     11,     2022},
		{   128,     11,     2040},
		{   129,     12,     4090},
		{   130,     10,     1003},
		{   131,      9,      477},
		{   132,      9,      467},
		{   133,      9,      473},
		{   134,      9,      475},
		{   135,     10,      978},
		{   136,     10,      972},
		{   137,     10,      988},
		{   138,     10,     1002},
		{   139,     11,     2029},
		{   140,     11,     2035},
		{   141,     11,     2041},
		{   142,     12,     4089},
		{   143,     11,     2034},
		{   144,     10,      974},
		{   145,      9,      484},
		{   146,     10,      971},
		{   147,     10,      984},
		{   148,     10,      982},
		{   149,     10,      994},
		{   150,     10,      997},
		{   151,     11,     2024},
		{   152,     11,     2036},
		{   153,     11,     2037},
		{   154,     11,     2039},
		{   155,     12,     4091},
		{   156,     11,     2042},
		{   157,     10,     1004},
		{   158,     10,      991},
		{   159,     10,      993},
		{   160,     10,      996},
		{   161,     10,      998},
		{   162,     10,     1008},
		{   163,     11,     2025},
		{   164,     11,     2031},
		{   165,     12,     4088},
		{   166,     12,     4094},
		{   167,     12,     4092},
		{   168,     12,     4095}
	};

	public final int[][] book11 = {
		/*index  length  codeword */
		{     0,      4,        0},
		{     1,      5,        6},
		{     2,      6,       25},
		{     3,      7,       61},
		{     4,      8,      156},
		{     5,      8,      198},
		{     6,      9,      423},
		{     7,     10,      912},
		{     8,     10,      962},
		{     9,     10,      991},
		{    10,     11,     2022},
		{    11,     11,     2035},
		{    12,     12,     4091},
		{    13,     11,     2028},
		{    14,     12,     4090},
		{    15,     12,     4094},
		{    16,     10,      910},
		{    17,      5,        5},
		{    18,      4,        1},
		{    19,      5,        8},
		{    20,      6,       20},
		{    21,      7,       55},
		{    22,      7,       66},
		{    23,      8,      146},
		{    24,      8,      175},
		{    25,      9,      401},
		{    26,      9,      421},
		{    27,      9,      437},
		{    28,     10,      926},
		{    29,     10,      960},
		{    30,     10,      930},
		{    31,     10,      973},
		{    32,     11,     2006},
		{    33,      8,      174},
		{    34,      6,       23},
		{    35,      5,        7},
		{    36,      5,        9},
		{    37,      6,       24},
		{    38,      7,       57},
		{    39,      7,       64},
		{    40,      8,      142},
		{    41,      8,      163},
		{    42,      8,      184},
		{    43,      9,      409},
		{    44,      9,      428},
		{    45,      9,      449},
		{    46,     10,      945},
		{    47,     10,      918},
		{    48,     10,      958},
		{    49,     10,      970},
		{    50,      8,      157},
		{    51,      7,       60},
		{    52,      6,       21},
		{    53,      6,       22},
		{    54,      6,       26},
		{    55,      7,       59},
		{    56,      7,       68},
		{    57,      8,      145},
		{    58,      8,      165},
		{    59,      8,      190},
		{    60,      9,      406},
		{    61,      9,      430},
		{    62,      9,      441},
		{    63,     10,      929},
		{    64,     10,      913},
		{    65,     10,      933},
		{    66,     10,      981},
		{    67,      8,      148},
		{    68,      8,      154},
		{    69,      7,       54},
		{    70,      7,       56},
		{    71,      7,       58},
		{    72,      7,       65},
		{    73,      8,      140},
		{    74,      8,      155},
		{    75,      8,      176},
		{    76,      8,      195},
		{    77,      9,      414},
		{    78,      9,      427},
		{    79,      9,      444},
		{    80,     10,      927},
		{    81,     10,      911},
		{    82,     10,      937},
		{    83,     10,      975},
		{    84,      8,      147},
		{    85,      8,      191},
		{    86,      7,       62},
		{    87,      7,       63},
		{    88,      7,       67},
		{    89,      7,       69},
		{    90,      8,      158},
		{    91,      8,      167},
		{    92,      8,      185},
		{    93,      9,      404},
		{    94,      9,      418},
		{    95,      9,      442},
		{    96,      9,      451},
		{    97,     10,      934},
		{    98,     10,      935},
		{    99,     10,      955},
		{   100,     10,      980},
		{   101,      8,      159},
		{   102,      9,      416},
		{   103,      8,      143},
		{   104,      8,      141},
		{   105,      8,      144},
		{   106,      8,      152},
		{   107,      8,      166},
		{   108,      8,      182},
		{   109,      8,      196},
		{   110,      9,      415},
		{   111,      9,      431},
		{   112,      9,      447},
		{   113,     10,      921},
		{   114,     10,      959},
		{   115,     10,      948},
		{   116,     10,      969},
		{   117,     10,      999},
		{   118,      8,      168},
		{   119,      9,      438},
		{   120,      8,      171},
		{   121,      8,      164},
		{   122,      8,      170},
		{   123,      8,      178},
		{   124,      8,      194},
		{   125,      8,      197},
		{   126,      9,      408},
		{   127,      9,      420},
		{   128,      9,      440},
		{   129,     10,      908},
		{   130,     10,      932},
		{   131,     10,      964},
		{   132,     10,      966},
		{   133,     10,      989},
		{   134,     10,     1000},
		{   135,      8,      173},
		{   136,     10,      943},
		{   137,      9,      402},
		{   138,      8,      189},
		{   139,      8,      188},
		{   140,      9,      398},
		{   141,      9,      407},
		{   142,      9,      410},
		{   143,      9,      419},
		{   144,      9,      433},
		{   145,     10,      909},
		{   146,     10,      920},
		{   147,     10,      951},
		{   148,     10,      979},
		{   149,     10,      977},
		{   150,     10,      987},
		{   151,     11,     2013},
		{   152,      8,      180},
		{   153,     10,      990},
		{   154,      9,      425},
		{   155,      9,      411},
		{   156,      9,      412},
		{   157,      9,      417},
		{   158,      9,      426},
		{   159,      9,      429},
		{   160,      9,      435},
		{   161,     10,      907},
		{   162,     10,      946},
		{   163,     10,      952},
		{   164,     10,      974},
		{   165,     10,      993},
		{   166,     10,      992},
		{   167,     11,     2002},
		{   168,     11,     2021},
		{   169,      8,      183},
		{   170,     11,     2019},
		{   171,      9,      443},
		{   172,      9,      424},
		{   173,      9,      422},
		{   174,      9,      432},
		{   175,      9,      434},
		{   176,      9,      439},
		{   177,     10,      923},
		{   178,     10,      922},
		{   179,     10,      954},
		{   180,     10,      949},
		{   181,     10,      982},
		{   182,     11,     2007},
		{   183,     10,      996},
		{   184,     11,     2008},
		{   185,     11,     2026},
		{   186,      8,      186},
		{   187,     11,     2024},
		{   188,     10,      928},
		{   189,      9,      445},
		{   190,      9,      436},
		{   191,     10,      906},
		{   192,      9,      452},
		{   193,     10,      914},
		{   194,     10,      938},
		{   195,     10,      944},
		{   196,     10,      956},
		{   197,     10,      983},
		{   198,     11,     2004},
		{   199,     11,     2012},
		{   200,     11,     2011},
		{   201,     11,     2005},
		{   202,     11,     2032},
		{   203,      8,      193},
		{   204,     11,     2043},
		{   205,     10,      968},
		{   206,     10,      931},
		{   207,     10,      917},
		{   208,     10,      925},
		{   209,     10,      940},
		{   210,     10,      942},
		{   211,     10,      965},
		{   212,     10,      984},
		{   213,     10,      994},
		{   214,     10,      998},
		{   215,     11,     2020},
		{   216,     11,     2023},
		{   217,     11,     2016},
		{   218,     11,     2025},
		{   219,     11,     2039},
		{   220,      9,      400},
		{   221,     11,     2034},
		{   222,     10,      915},
		{   223,      9,      446},
		{   224,      9,      448},
		{   225,     10,      916},
		{   226,     10,      919},
		{   227,     10,      941},
		{   228,     10,      963},
		{   229,     10,      961},
		{   230,     10,      978},
		{   231,     11,     2010},
		{   232,     11,     2009},
		{   233,     11,     2015},
		{   234,     11,     2027},
		{   235,     11,     2036},
		{   236,     11,     2042},
		{   237,      9,      405},
		{   238,     11,     2040},
		{   239,     10,      957},
		{   240,     10,      924},
		{   241,     10,      939},
		{   242,     10,      936},
		{   243,     10,      947},
		{   244,     10,      953},
		{   245,     10,      976},
		{   246,     10,      995},
		{   247,     10,      997},
		{   248,     11,     2018},
		{   249,     11,     2014},
		{   250,     11,     2029},
		{   251,     11,     2033},
		{   252,     11,     2041},
		{   253,     11,     2044},
		{   254,      9,      403},
		{   255,     12,     4093},
		{   256,     10,      988},
		{   257,     10,      950},
		{   258,     10,      967},
		{   259,     10,      972},
		{   260,     10,      971},
		{   261,     10,      985},
		{   262,     10,      986},
		{   263,     11,     2003},
		{   264,     11,     2017},
		{   265,     11,     2030},
		{   266,     11,     2031},
		{   267,     11,     2037},
		{   268,     11,     2038},
		{   269,     12,     4092},
		{   270,     12,     4095},
		{   271,      9,      413},
		{   272,      9,      450},
		{   273,      8,      181},
		{   274,      8,      161},
		{   275,      8,      150},
		{   276,      8,      151},
		{   277,      8,      149},
		{   278,      8,      153},
		{   279,      8,      160},
		{   280,      8,      162},
		{   281,      8,      172},
		{   282,      8,      169},
		{   283,      8,      177},
		{   284,      8,      179},
		{   285,      8,      187},
		{   286,      8,      192},
		{   287,      9,      399},
		{   288,      5,        4}
	};

	public final int[][] bookscl = {
		/*index  length  codeword */
		{     0,     18,   262120},
		{     1,     18,   262118},
		{     2,     18,   262119},
		{     3,     18,   262117},
		{     4,     19,   524277},
		{     5,     19,   524273},
		{     6,     19,   524269},
		{     7,     19,   524278},
		{     8,     19,   524270},
		{     9,     19,   524271},
		{    10,     19,   524272},
		{    11,     19,   524284},
		{    12,     19,   524285},
		{    13,     19,   524287},
		{    14,     19,   524286},
		{    15,     19,   524279},
		{    16,     19,   524280},
		{    17,     19,   524283},
		{    18,     19,   524281},
		{    19,     18,   262116},
		{    20,     19,   524282},
		{    21,     18,   262115},
		{    22,     17,   131055},
		{    23,     17,   131056},
		{    24,     16,    65525},
		{    25,     17,   131054},
		{    26,     16,    65522},
		{    27,     16,    65523},
		{    28,     16,    65524},
		{    29,     16,    65521},
		{    30,     15,    32758},
		{    31,     15,    32759},
		{    32,     14,    16377},
		{    33,     14,    16373},
		{    34,     14,    16375},
		{    35,     14,    16371},
		{    36,     14,    16374},
		{    37,     14,    16370},
		{    38,     13,     8183},
		{    39,     13,     8181},
		{    40,     12,     4089},
		{    41,     12,     4087},
		{    42,     12,     4086},
		{    43,     11,     2041},
		{    44,     12,     4084},
		{    45,     11,     2040},
		{    46,     10,     1017},
		{    47,     10,     1015},
		{    48,     10,     1013},
		{    49,      9,      504},
		{    50,      9,      503},
		{    51,      8,      250},
		{    52,      8,      248},
		{    53,      8,      246},
		{    54,      7,      121},
		{    55,      6,       58},
		{    56,      6,       56},
		{    57,      5,       26},
		{    58,      4,       11},
		{    59,      3,        4},
		{    60,      1,        0},
		{    61,      4,       10},
		{    62,      4,       12},
		{    63,      5,       27},
		{    64,      6,       57},
		{    65,      6,       59},
		{    66,      7,      120},
		{    67,      7,      122},
		{    68,      8,      247},
		{    69,      8,      249},
		{    70,      9,      502},
		{    71,      9,      505},
		{    72,     10,     1012},
		{    73,     10,     1014},
		{    74,     10,     1016},
		{    75,     11,     2037},
		{    76,     11,     2036},
		{    77,     11,     2038},
		{    78,     11,     2039},
		{    79,     12,     4085},
		{    80,     12,     4088},
		{    81,     13,     8180},
		{    82,     13,     8182},
		{    83,     13,     8184},
		{    84,     14,    16376},
		{    85,     14,    16372},
		{    86,     16,    65520},
		{    87,     15,    32756},
		{    88,     16,    65526},
		{    89,     15,    32757},
		{    90,     18,   262114},
		{    91,     19,   524249},
		{    92,     19,   524250},
		{    93,     19,   524251},
		{    94,     19,   524252},
		{    95,     19,   524253},
		{    96,     19,   524254},
		{    97,     19,   524248},
		{    98,     19,   524242},
		{    99,     19,   524243},
		{   100,     19,   524244},
		{   101,     19,   524245},
		{   102,     19,   524246},
		{   103,     19,   524274},
		{   104,     19,   524255},
		{   105,     19,   524263},
		{   106,     19,   524264},
		{   107,     19,   524265},
		{   108,     19,   524266},
		{   109,     19,   524267},
		{   110,     19,   524262},
		{   111,     19,   524256},
		{   112,     19,   524257},
		{   113,     19,   524258},
		{   114,     19,   524259},
		{   115,     19,   524260},
		{   116,     19,   524261},
		{   117,     19,   524247},
		{   118,     19,   524268},
		{   119,     19,   524276},
		{   120,     19,   524275}
	};
	
	Hcb[]	book = new Hcb[Constants.NSPECBOOKS+2];
	
	float[] iq_exp_tbl = new float[Constants.MAX_IQ_TBL];
	
	float[]	exptable = new float[Constants.TEXP];
	
	/** The input MPEG4 audio bitstream. */
	private BitStream bitstream;

	/**
	 * Constructs an <code>Huffman</code> object using the specified bitstream object.
	 * @param bitstream the input video bitstream.
	 */	
	public Huffman(AACDecoder decoder) {
		super();
		this.bitstream = decoder.getAudio_Stream();
		for(int i = 0; i < book.length; i++) {
			book[i] = new Hcb();
		}
		huffbookinit();
	}
	
	/**
	 * Coverts long to binary string.
	 * @param v the long value.
	 * @param len the amount of bits in the long value to be printed.
	 * @return the binary string of a long value. 
	 */
	final static String bin_str(long v, int len) {
		return Long.toBinaryString((v & ((1 << len) - 1)) | 1 << len).substring(1);
	}

	/**
	 * Prints the huffman codebook.
	 * @param hcb the huffman codebook.
	 */
	static void print_cb(Hcb hcb) {
		int[][] hcw = hcb.hcw;
		System.out.println("Huffman Codebook");
		System.out.println("size " + hcb.n + ", dim " + hcb.dim + ", lav " + hcb.lav + ", mod " + hcb.mod + ", off " + hcb.off + ", signed " + hcb.signed_cb);
		System.out.println("index\t length\t cw_10\t cw_2");
		for (int i = 0; i < hcb.n; i++) {
			System.out.println(hcw[i][0] + "\t\t " + hcw[i][1] + "\t\t " + hcw[i][2] + "\t\t " + bin_str(hcw[i][2], hcw[i][1]));
		}
	}    

	/**
	 * Compares two huffman records.
	 * @param va first huffman record.
	 * @param vb second huffman record.
	 * @return the comparation result.  
	 */
	static int huffcmp(Object va, Object vb)
	{
		int[] a, b;

		a = (int[])va;
		b = (int[])vb;
		if (a[1] < b[1])
		return -1;
		if ( (a[1] == b[1]) && (a[2] < b[2]) )
		return -1;
		return 1;
	}

	/**
	 * Initialize the Hcb structure and sort the Huffman
	 * codewords by length, shortest (most probable) first
	 * @param Hcb the Huffman codebook.
	 * @param hcw the Huffman table.
	 */
	void hufftab(Hcb hcb, int[][] hcw, int dim, int lav, boolean signed_cb)
	{
		int i, j, n;
		int[] tmp;
    
		if (!signed_cb) {
			hcb.mod = lav + 1;
			hcb.off = 0;
		} else {
			hcb.mod = 2*lav + 1;
			hcb.off = lav;
		}
		n = 1;	    
		for (i = 0; i < dim; i++) {
			n *= hcb.mod;
		}
		hcb.n = n;
		hcb.dim = dim;
		hcb.lav = lav;
		hcb.signed_cb = signed_cb;
		hcb.hcw = hcw;

//		if (debug['H'] && !debug['S']) print_cb(hcb);
		for(i = hcw.length - 1; i > 0; i--) {
			for(j = 0; j < i; j++) {
				if(huffcmp(hcw[i], hcw[j]) == -1) {
					tmp = hcw[i];
					hcw[i] = hcw[j];
					hcw[j] = tmp;
				}
			}
		}
//		if (debug['H'] && debug['S']) print_cb(hcb);
	}
 
 	/**
 	 * Decodes the huffman codeword from a stream.
 	 * @param  h the huffman table.
 	 * @return the decoded value.
 	 * @throws IOException raises if an I/O error occurs.
 	 */
	int	decode_huff_cw(int[][] h) throws IOException {
		/*
		 * Cword is working buffer to which shorts from
		 *   bitstream are written. Bits are read from msb to lsb
		 * Nbits is number of lsb bits not yet consumed
		 * 
		 * this uses a minimum-memory method of Huffman decoding
		 */
//		System.out.println("decode_huff_cw");
		int i, j, z = 0;
		long cw;
    
		i = h[z][1];
		cw = bitstream.next_bits(i);
		while (cw != h[z][2]) {
			z++;
			j = h[z][1]-i;
			i += j;
			cw <<= j;
			cw |= bitstream.next_bits(j);
		}
		return(h[z][0]);
	}


	/** checked */
	void unpack_idx(int[] qp, int qp_start_index, int idx, Hcb hcb)
	{
		int dim = hcb.dim;
		int mod = hcb.mod;
		int off = hcb.off;
		if(dim == 4){
			qp[qp_start_index + 0] = (idx/(mod*mod*mod)) - off;
			idx -= (qp[qp_start_index + 0] + off)*(mod*mod*mod);
			qp[qp_start_index + 1] = (idx/(mod*mod)) - off;
			idx -= (qp[qp_start_index + 1] + off)*(mod*mod);
			qp[qp_start_index + 2] = (idx/(mod)) - off;
			idx -= (qp[qp_start_index + 2] + off)*(mod);
			qp[qp_start_index + 3] = (idx) - off;
		}
		else {
			qp[qp_start_index + 0] = (idx/(mod)) - off;
			idx -= (qp[qp_start_index + 0] + off)*(mod);
			qp[qp_start_index + 1] = (idx) - off;
		}
	}

	// get sign bits 
	/** checked */
	void get_sign_bits(int[] q, int qp_start_index, int n) throws IOException {
		int i;

		for (i = 0; i < n; i++) {
			if (q[qp_start_index + i] > 0) {
				if (bitstream.next_bit()) {
					// 1 signals negative, as in 2's complement
					q[qp_start_index + i] = -q[qp_start_index + i];
				}
			}
		}
	}

	/* source huffinit.c */	
	void huffbookinit() {
		int i;

		hufftab(book[1], book1, 4, 1, Constants.HUF1SGN);
		hufftab(book[2], book2, 4, 1, Constants.HUF2SGN);
		hufftab(book[3], book3, 4, 2, Constants.HUF3SGN);
		hufftab(book[4], book4, 4, 2, Constants.HUF4SGN);
		hufftab(book[5], book5, 2, 4, Constants.HUF5SGN);
		hufftab(book[6], book6, 2, 4, Constants.HUF6SGN);
		hufftab(book[7], book7, 2, 7, Constants.HUF7SGN);
		hufftab(book[8], book8, 2, 7, Constants.HUF8SGN);
		hufftab(book[9], book9, 2, 12, Constants.HUF9SGN);
		hufftab(book[10], book10, 2, 12, Constants.HUF10SGN);
		hufftab(book[11], book11, 2, 16, Constants.HUF11SGN);

		hufftab(book[Constants.BOOKSCL], bookscl, 1, 60, true);

		for(i = 0; i < Constants.TEXP; i++){
			exptable[i]  = (float)Math.pow( 2.0,  0.25*i);
		}

		for(i = 0; i < Constants.MAX_IQ_TBL; i++){
			iq_exp_tbl[i] = (float)Math.pow(i, 4./3.);
		}
	}

}
